package com.ssh;

import org.junit.Test;

public class StrStr_28 {
	public int strStr(String haystack, String needle) {
		return haystack.indexOf(needle);
    }
	public int strStr1(String haystack, String needle) {
		if (needle.isEmpty()) {
			return 0;
		}
		for (int i = 0; i <= haystack.length() - needle.length(); i++) {
			for (int j = 0; j < needle.length() && haystack.charAt(i + j) == needle.charAt(j); j++) {
				if (j == needle.length() - 1) {
					return i;
				}
			}
			
		}
		return -1;
    }
	@Test
	public void test () {
		System.out.println(strStr1("mississippi" ,"issip"));
	}
	
}
